﻿using System.Collections.Generic;
using System.Web.Mvc;
using System;

namespace Jw.Web.App_Start
{
    public class BaseController : Controller
    {
        private List<string> _macs = null;
        private List<string> macs
        {
            get
            {
                if (_macs == null)
                {

                    _macs = new List<string>();
                    _macs.Add("00:E0:4C:7C:7B:79"); //xiaoping
                    _macs.Add("6C:71:D9:8B:7F:CC");//无线
                    _macs.Add("74:27:EA:AE:1A:F7");//Host 74-27-EA-AE-1A-F7
                    _macs.Add("C4:54:44:0B:B8:6F"); //192.168.1.7 
                }
                return _macs;
            }
        }

        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            //判断加密狗日期
            string error = "";
            if (!Request.IsLocal)
            {
                error = "";
                //验证狗及日期
                //if (ET99_Utilities.FindET99Dog(ref error) == false)
                //{
                //    filterContext.Result = new ContentResult() { Content = error };
                //}
                //else
                //日期限制
                if (Jw.Core.APP.CUS_DATE_LIMIT < DateTime.Now)
                {
                    error = "已经过期，无法继续使用，请联系管理员！";
                    filterContext.Result = new ContentResult() { Content = error };
                }
                else
                {
                    //增加授权Mac
                    string serverMac = Jw.Utils.Helper.NetHelper.GetMACAddress();
                    if (!macs.Contains(serverMac))
                    {
                        error = "该版本程序只能用于开发模式，不可以运行至布署模式！请联系软件开发商.  特征码：" + string.Format("00x{0}x0$", serverMac.Replace(':', '$'));
                        filterContext.Result = new ContentResult() { Content = error };
                    }
                }


            }
            base.OnActionExecuted(filterContext);
        }
    }
}